﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace sqCore
{
    public class TimeToLocalTimeCoverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime input;
            if (value.GetType() == typeof(DateTime))
            {
                input = (DateTime)value;
                return input.ToLocalTime();
            }
            else
                return DateTime.Now.ToLocalTime();                
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime input;
            if (value.GetType() == typeof(DateTime))
            {
                input = (DateTime)value;
                return input.ToUniversalTime();
            }
            else
                return DateTime.Now.ToUniversalTime();
        }
    }
}
